package com.study.jvm.directmemory;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

//java.lang.OutOfMemoryError: Direct buffer memory
public class DirectMemoryOom {
    private static final int _100MB = 1024 * 1024 * 100;

    public static void main(String[] args) {
        int count = 0;
        try {
            List<ByteBuffer> byteBuffers = new ArrayList<>();
            while (true) {
                ByteBuffer byteBuffer = ByteBuffer.allocateDirect(_100MB);
                byteBuffers.add(byteBuffer);
                count++;
            }
        } catch (Throwable throwable) {
            System.out.println("count = " + count);
            throwable.printStackTrace();
        }
    }
}
